package org.hrqing.authorization.entity;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.Column;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;
import org.hrqing.authorization.entity.mapper.BaseEntity;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * @auther Hrqing
 */
@Getter
@Setter
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "t_authorization")
public class Authorization extends BaseEntity {

    private String registeredClientId;

    private String principalName;

    private String authorizationGrantType;

    @Column(columnDefinition = "varchar")
    private String authorizedScopes;

    @JdbcTypeCode(SqlTypes.JSON)
    private String attributes;

    @Column(columnDefinition = "varchar")
    private String state;

    @Column(columnDefinition = "varchar")
    private String authorizationCodeValue;

    private LocalDateTime authorizationCodeIssuedAt;

    private LocalDateTime authorizationCodeExpiresAt;

    @JdbcTypeCode(SqlTypes.JSON)
    private String authorizationCodeMetadata;

    @Column(columnDefinition = "varchar")
    private String accessTokenValue;

    private LocalDateTime accessTokenIssuedAt;

    private LocalDateTime accessTokenExpiresAt;

    @JdbcTypeCode(SqlTypes.JSON)
    private String accessTokenMetadata;

    private String accessTokenType;

    @Column(columnDefinition = "varchar")
    private String accessTokenScopes;

    @Column(columnDefinition = "varchar")
    private String refreshTokenValue;

    private LocalDateTime refreshTokenIssuedAt;

    private LocalDateTime refreshTokenExpiresAt;

    @JdbcTypeCode(SqlTypes.JSON)
    private String refreshTokenMetadata;

    @Column(columnDefinition = "varchar")
    private String oidcIdTokenValue;

    private LocalDateTime oidcIdTokenIssuedAt;

    private LocalDateTime oidcIdTokenExpiresAt;

    @JdbcTypeCode(SqlTypes.JSON)
    private String oidcIdTokenMetadata;

    @JdbcTypeCode(SqlTypes.JSON)
    private String oidcIdTokenClaims;

    @Column(columnDefinition = "varchar")
    private String userCodeValue;

    private LocalDateTime userCodeIssuedAt;

    private LocalDateTime userCodeExpiresAt;

    @JdbcTypeCode(SqlTypes.JSON)
    private String userCodeMetadata;

    @Column(columnDefinition = "varchar")
    private String deviceCodeValue;

    private LocalDateTime deviceCodeIssuedAt;

    private LocalDateTime deviceCodeExpiresAt;

    @JdbcTypeCode(SqlTypes.JSON)
    private String deviceCodeMetadata;
}
